import {Promise} from 'es6-promise';
import {Role} from "../core/defines";
import * as utils from '../core/utils';
import {MongoColls} from '../config/mongo';
import {CursorType} from "../core/defines";
import {BaseModel} from "../core/base.model";
import {Collection, ObjectID} from "mongodb";
import {
    FindParam,
    CountParam,
    UpdateParam,
    FindOneParam,
    AggregateParam,
    FindOneUpdateParam,
} from "../core/params";

export enum RedPacketStatus {
    PENDING = 1,
    ORDERED = 2,
    DELETED = 3,
}

export interface RedPacketInfo {
    _id?: ObjectID,
    code?: string,
    name: string,
    type?: number,
    stime: Date,
    etime: Date,
    limit?: number,
    amount?: number,
    status?: RedPacketStatus,
    time?: Date
}

export interface RedPacketFilter {
    _id?: ObjectID,
    page?: number,
    limit?: number,
}

export default class RedPacketModel extends BaseModel {
    name() {
        return 'RedPacketModel';
    }

    constructor(coll: Collection) {
        super(coll);
    }

    checkExist(filter: RedPacketFilter): Promise<any> {
        return this.findOne(new FindOneParam(filter));
    }

}
